var Partida = {};

Partida.HTML = function(p, full) {
	var html = '';
	if (notSet(p.k)) { return html; }

	if (full) {
		html += '<div class="partida" id="p' + p.k + '" ' +
			'title="Κλικ για είσοδο" ' +
			'onclick="Partida.isodos(' + p.k + ');">' +
			'<div id="i' + p.k + '" class="partidaInfo"></div>';
	}

	html += '<div class="kodikos">' + p.k + '</div>';
	html += this.pektisHTML(p, 1);
	html += this.pektisHTML(p, 2);

	if (full) {
		html += '</div>';
	}

	return html;
};

Partida.pektisHTML = function(partida, thesi) {
	var html = '';
	html += '<div class="pektis pektis' + thesi + '">';
	if (partida.hasOwnProperty('p' + thesi)) {
		html += partida['p' + thesi];
	}
	html += '</div>';
	return html;
};

Partida.isodos = function(partida) {
	var req = newRequest();
	if (notSet(req)) { return false; }

	req.onreadystatechange = function() {
		Partida.isodosCheck(req, x);
	};
	openRequest(req, 'fantasmatakia/isodos');

	var params = 'partida=' + uri(partida);

	var x = getelid('i' + partida);
	if (isSet(x)) {
		x.innerHTML = '<img src="' + globals.server +
			'images/working.gif" class="isodosWorking" />';
	}
	req.send(params);
};

Partida.isodosCheck = function(req, info) {
	if (req.readyState != 4) {
		return;
	}

	info.innerHTML = '';
	if (req.status != 200) {
		return;
	}

	if (req.responseText) {
		fyi(req.responseText);
	}
};
